﻿using RFBR.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RFBR.Filter
{
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
    public class KnowledgeBaseExistAttribute : FilterAttribute, IActionFilter
    {
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            
        }

        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var kb = filterContext.HttpContext.Session[SessionKey.KnowledgeBase];
            if (kb == null)
            {
                filterContext.Result = new JsonResult()
                {
                    Data = null
                };
            }
        }
    }
}